<?php

namespace app\admin\model;

use think\Db;
use think\Model;

class Writer extends Model
{
    public function index()
    {

        $list = Db::table('lp_writer')->select();
        return $list;
        // var_dump($list);die;
        
    }

    public function doAdd($data)
    {
        if ($data['pwd'] != $data['repwd']) {
            $this->error('密码不一致');
        }
        unset($data['repwd']);
        $list = Db::table('lp_writer')->insert($data);
        return $list;
    }

    public function doDelete($id)
    {
        $res = Db::table('lp_writer')->delete($id);
        // var_dump($res);die;
        return $res;
    }

    public function doEdit($data)
    {
        if ($data['pwd'] != $data['repwd']) {
            $this->error('密码不一致');
        }
        unset($data['repwd']);
        $list = Db::table('lp_writer')->where('id', 'eq', $data['id'])->update($data);
        return $list;
    }
}